<cfinclude template="/code_lib/SCF_Employee.cfm">
<cfinclude template="/code_lib/SCF_HR.cfm">
<cfinclude template="/code_lib/SCF_REGEX.cfm">

<cfset Session.strUserID = ListGetAt(CGI.Auth_User, 2, '\') />
<cfset Session.arrEmpInfo = SCF_Employee_GetEmpInfo_FromLogin(CGI.Auth_User) />
<cfset Session.intUserRosettaID = Session.arrEmpInfo.MasterID />
<cfset Session.intHRID = SCF_HR_MasterID_to_HRPersonID(Session.arrEmpInfo.MasterID) />
<cfset Session.ADMIN = "ADMIN" />
<cfset Session.HR = "HR" />
<cfset Session.IT = "IT" />
<cfset Session.FINANCE = "FINANCE" />
<cfset Session.FACILITIES = "FACILITIES" />
<cfset Session.MANAGERS = "MANAGERS" />
<cfset Session.LIAISONS = "LIAISONS" />
<cfset Session.bolManager = False />
<cfset Session.SERVICEDESK_EMAIL = "bfrick@scf.cc" />
<cfset Session.ITS_EMAIL = "bfrick@scf.cc" />
<cfset Session.FormComments = "" />

<cfset Session.DataSource = "EPAR" />
<cfset Session.DataSourceWFCDB = "KRONOS" />
<cfset Session.DataSourceRosetta = "RosettaStone" />
<cfset Session.DataSourceAccessControl = "AccessControl" />
<cfset Session.DataSourceSCF_General = "SCF_General" />


<cfldap 
	action="query" 
	attributes="memberOf, displayname" 
	filter="(sAMAccountName=#Session.strUserID#)" 
	username="userlist" 
	password="DefinedMan" 
	name="qryGroup" 
	start="OU=SCFUsers,DC=Southcentralfoundation,DC=COM" 
	server="10.100.1.101">
	
<cfquery name="qryGroupCheckManagers" dbtype="query">
	Select * from qryGroup
	Where memberOf like '%SCF Managers DL%' or memberOf like '%Hiring Delegates%'
</cfquery>

<cfquery name="qryGroupCheckIT" dbtype="query">
	Select * from qryGroup
	Where memberOf like '%SCF Information Technology Services%'
</cfquery>

<cfquery name="qryGroupCheckHR" dbtype="query">
	Select * from qryGroup
	Where memberOf like '%SCF Human Resources%'
</cfquery>

<cfquery name="qryGroupCheckFN" dbtype="query">
	Select * from qryGroup
	Where memberOf like '%SCF Finance Operations%'
</cfquery>

<cfquery name="qryGroupCheckFA" dbtype="query">
	Select * from qryGroup
	Where memberOf like '%SCF Facilities%'
</cfquery>

<cfquery name="qryGroupCheckCL" dbtype="query">
	Select * from qryGroup
	Where memberOf like '%SCF Contract Liaisons%'
</cfquery>

<cfif qryGroupCheckIT.recordcount GT 0>
	<cfset Session.bolAuth = True>
	<cfset Session.strAuthType =Session.IT>
<cfelseif qryGroupCheckHR.recordcount GT 0>
	<cfset Session.bolAuth = True>
	<cfset Session.strAuthType = Session.HR>
<cfelseif qryGroupCheckFN.recordcount GT 0>
	<cfset Session.bolAuth = True>
	<cfset Session.strAuthType =Session.FINANCE>
<cfelseif qryGroupCheckFA.recordcount GT 0>
	<cfset Session.bolAuth = True>
	<cfset Session.strAuthType =Session.FACILITIES>
<cfelseif qryGroupCheckCL.recordcount GT 0> 
	<cfset Session.bolAuth = True>
	<cfset Session.strAuthType = Session.LIAISONS>
<cfelseif qryGroupCheckManagers.recordcount GT 0> 
	<cfset Session.bolAuth = True>
	<cfset Session.strAuthType = Session.MANAGERS>
<cfelse>
	<cfset Session.bolAuth = False>
	<cfset Session.strAuthType ="">
</cfif>

<cfif Session.strAuthType NEQ "" AND Session.strAuthType NEQ Session.MANAGERS>
	<!--- Check to see if they are additionally in the managers group--->
    <cfif qryGroupCheckManagers.recordcount GT 0> 
		<cfset Session.bolManager = True>
    </cfif>
</cfif>
